package cn.edu.lzu.platformweb.controller;

import cn.edu.lzu.entity.City;
import cn.edu.lzu.service.CityService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class CityController {
    @Resource
    private CityService cityService;

    /*
     * @Author: 张琦[QQ:3098086691]
     * @Description: TODO 从数据库中查出所有的省级记录
     * @Date: 2019/11/26 10:59
     * @Param: []
     * @return: java.util.List<cn.edu.lzu.entity.City>
     **/
    @ResponseBody
    @RequestMapping("/getAllProvince")
    public List<City> getAllProvince(){
        List<City> provinceList=cityService.selectAllProvince();
        return provinceList;
    }
    
    /**
     * @Author: 张琦[QQ:3098086691]
     * @Description: TODO 根据省级单位的ID查出数据库中该省的所有市级记录
     * @Date: 2019/11/26 11:01
     * @Param: [provinceId]
     * @Return: java.util.List<cn.edu.lzu.entity.City>
     **/
    @ResponseBody
    @RequestMapping("/getAllCityByProvinceId")
    public List<City> getAllCityByProvinceId(long provinceId){
        List<City> cityList=cityService.selectAllCityByProvinceId(provinceId);
        return cityList;
    }

    /**
     * @Author: 张琦[QQ:3098086691]
     * @Description: TODO 根据市级单位的ID查出数据库中该市所有的县区级记录
     * @Date: 2019/11/26 11:06
     * @Param: [cityId]
     * @Return: java.util.List<cn.edu.lzu.entity.City>
     **/
    @ResponseBody
    @RequestMapping("/getAllCountyByCityId")
    public List<City> getAllCountyByCityId(long cityId){
        List<City> countyList=cityService.selectAllCountyByCityId(cityId);
        return countyList;
    }



}
